package com.aooci.ordercat.dao.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate4.HibernateCallback;

import com.aooci.ordercat.dao.DiningTableDAO;
import com.aooci.ordercat.domain.DiningTable;
import com.aooci.ordercat.enums.DiningTableStatus;

/**
 * A data access object (DAO) providing persistence and search support for
 * Account entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.bitongline.lgs.dao.Account
 */
public class DiningTableDAOImpl extends AbstractBaseDAOImpl<DiningTable, Integer> implements DiningTableDAO {

	public DiningTableDAOImpl() {
		super(DiningTable.class);
	}

	private static final long serialVersionUID = -4236573107157049581L;
	private static final Logger log = Logger.getLogger(DiningTableDAOImpl.class);
	@Override
	public List<DiningTable> findTableByCategoryIdAndStatus(final int diningTableCategoryId, final DiningTableStatus status) {
	    return getHibernateTemplate().execute(new HibernateCallback<List<DiningTable>>(){
	        @SuppressWarnings("unchecked")
			@Override  
	        public List<DiningTable> doInHibernate(Session session) {  
	        	Query query = session.getNamedQuery("DINING_TABLE.findTableByCategoryIdAndStatus");
	        	query.setParameter("diningTableCategoryId", diningTableCategoryId);
	        	query.setParameter("status", status);
	            return (List<DiningTable>)query.list();  
	        }  
	    });
	}
	@Override
	public List<DiningTable> findTableByCategoryId(final int diningTableCategoryId) {
	    return getHibernateTemplate().execute(new HibernateCallback<List<DiningTable>>(){
	        @SuppressWarnings("unchecked")
			@Override  
	        public List<DiningTable> doInHibernate(Session session) {  
	        	Query query = session.getNamedQuery("DINING_TABLE.findTableByCategoryId");
	        	query.setParameter("diningTableCategoryId", diningTableCategoryId);
	            return (List<DiningTable>)query.list();  
	        }  
	    });
	}



}